const app = getApp()

Page({
  data: {
    userInfo: {},
    hasUserInfo: false,
    nickName: ''
  },
  onShow: function () {
    var _this = this;
    wx.getStorage({
      key: "nickName",
      success: function (res) {
        console.log(res.data)
        if(res.data){
          _this.setData({
            nickName: res.data.nickName
          })
        }
        console.log(_this.data.nickName)
      }
    })
    wx.setNavigationBarTitle({
      title: '编辑姓名'
    })
  },
  onLoad: function () {

  },

  getname:function(e){
    this.setData({
      nickName: e.detail.value
    })
  },
  formSubmit: function (e) {
    var nickNamesStorage = this.data.nickName;
    console.log("nickNamesStorage",nickNamesStorage);
    if (!nickNamesStorage ) {
      wx.showToast({
        title: '昵称不能为空',
        icon: 'seccess',
        duration: 1000,
        mask: true
      })
    }else {
      wx.setStorage({
        key: "nickName",
        data: e.detail.value
      })
      wx.navigateBack({
        delta: 1
      })
    }
    
  }
})